from django.db import models


# Create your models here.
# 用户表
class User(models.Model):
    username = models.CharField(max_length=277)  # 用户名
    email = models.EmailField()  # 邮箱
    password = models.CharField(max_length=120)  # 密码
    img = models.ImageField('static/img', null=True)  # 头像
    is_active = models.SmallIntegerField(default=1, choices=((1, '未激活'), (2, '激活')))  # 激活
    level = models.SmallIntegerField(default=1, choices=((1, '普通会员'), (2, 'vip会员')))  # 会员
    ingtegral = models.IntegerField(default=0)  # 积分
    invitation_code = models.CharField(max_length=120, null=True)  # 邀请码

    class Meta:
        db_table = 'q_user'


# 课程分类
class coursecate(models.Model):
    name = models.CharField(max_length=120)

    class Meta:
        db_table = 'q_kecheng'


# 课程标签
class coursebiao(models.Model):
    course = models.ForeignKey(coursecate, on_delete=models.CASCADE)
    course_tags = models.CharField(max_length=255)

    class Meta:
        db_table = 'q_course_tags'


class Courseniu(models.Model):
    title = models.CharField(max_length=255)  # 标题
    desc = models.CharField(max_length=255)  # 简介
    author = models.CharField(max_length=255)  # 作者
    price = models.CharField(max_length=255)  # 价格
    is_online = models.IntegerField(default=0)  # 是否上线,未上线0，上线是1
    pic = models.ImageField(upload_to='static/img')  # 图片
    flow = models.IntegerField(null=True)  # 关注
    read = models.IntegerField(null=True)  # 阅读
    type = models.IntegerField()  # 课程类型   免费1会员2训练营3
    createtime = models.DateTimeField(auto_now_add=True)  # 上线时间
    tags_id = models.ForeignKey(coursebiao, on_delete=models.CASCADE)  # 课程标签

    class Meta:
        db_table = 'course'

# 用户等级表
# class Userlevel(models.Model):
#     levenl = models.SmallIntegerField(default=1, choices=((1, '普通会员'), (2, 'vip会员')))  # 会员


# 用户等级条件表
# class UserlevelCondition(models.Model):
#     level = models.ForeignKey(Userlevel, on_delete=models.CASCADE)
#     time = models.DateTimeField()  # 时长
#     amout = models.DecimalField(max_digits=9, decimal_places=2)  # 价格


# 会员表
# class ThirdParnyLogin(models.Model):
#     user = models.ForeignKey(User, on_delete=models.CASCADE)
#     level = models.IntegerField()
#     start_time = models.DateTimeField()  # 开始时间
#     end_time = models.DateTimeField()  # 结束时间


# 会员订单记录表
# class Momber(models.Model):
#     order_sn = models.CharField(max_length=120)  # 订单号
#     user = models.ForeignKey(User, on_delete=models.CASCADE)  # 用户外键
#     level = models.IntegerField()  # 会员等级
#     time = models.DateTimeField()  # 时长
#     serial_number = models.CharField(max_length=120)  # 流水号
#     status = models.IntegerField()  # 订单状态
#     amout = models.DecimalField(max_digits=9, decimal_places=2)  # 总价
#     pay_type = models.SmallIntegerField(default=1, choices=((1, '微信支付'), (2, '支付宝支付')))  # 支付
#     code = models.CharField(max_length=130)  # 邀请码


# class Coupon(models.Model):
#     name = models.CharField(max_length=120)  # 优惠卷名称
#     count = models.IntegerField()  # 优惠卷数量
#     course_id = models.IntegerField()  # 优惠卷使用课程
#     start_time = models.DateTimeField()  # 使用开始时间
#     end_time = models.DateTimeField()  # 结束时间
#     dates = models.IntegerField()  # 有效天数
#     status = models.IntegerField()  # 优惠卷状态  可用，可过期
#     money = models.DecimalField(max_digits=9, decimal_places=2)  # 优惠卷金额


# class rule(models.Model):
#     ratio = models.FloatField(verbose_name='兑换')


# class Usercoupon(models.Model):
#     coupen = models.ForeignKey(Coupon, on_delete=models.CASCADE)
#     count = models.IntegerField()  # 优惠卷数量
#     is_use = models.IntegerField()  # 是否使用  0可以使用，1未使用


# class couponjilu(models.Model):
#     user = models.ForeignKey(User, on_delete=models.CASCADE)
#     x_integral = models.IntegerField()  # 使用积分
#     s_integral = models.IntegerField()  # 剩余积分
#     effect = models.IntegerField()  # 积分兑换用途，（0抵扣金额1兑换优惠卷）
#     coupon_code = models.CharField(max_length=120)  # 如果用于兑换优惠卷，则说明兑换优惠卷的吗


# class gongdan(models.Model):
#     user = models.ForeignKey(User, on_delete=models.CASCADE)
#     problem = models.CharField(max_length=120)  # 用户问题
#     pid = models.CharField(max_length=100)  # 关联问题
#     status = models.IntegerField()  # 状态，0未处理，1处理
